
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    VUEADF.Composite = function(parent) {
        VUEADF.Composite.superclass.constructor.call(this, parent);
        this.children = [];
        this.vueData = {
            name : "div",
            data : {
                children : []
            }
        }
    };
    COM.util.defineClass(VUEADF.Composite, VUEADF.Control, {
        getChildren: function(){
            return this.children;
        },
        addChild: function(child, index) {
            if(arguments.length == 2) {
                this.children.splice(index, 0, child);
            } else {
                this.children.push(child);
            }
            child.setParent(this);
            // this.appendDomChild(child.getDomElement());
            this.appendChildData(child.getVueData());
        },
        appendChildData : function(childData){
            this.vueData.data.children.push(childData);
        },
        removeChildData : function(childData){
            COM.util.Array.removeItem(this.vueData.data.children, childData);
        },
        appendDomChild: Function.needOverride,
        removeChild: function(child){
            COM.util.Array.removeItem(this.children, child);
            this.removeChildData(child.getVueData());
            // this.removeDomChild(child.getDomElement());
        },
        layoutChild: Function.emptyFunction,
        _childLayoutChanged : function(){
            return false;
        },
        removeDomChild: Function.needOverride,
        getChild: function(index) {
            if(0 < index && index < this.children.length) {
                return this.children[index];
            }
            return null;
        },
        clearChildren:function() {
            this.children = [];
        }
    });
})();